package com.jack.leetcode.eachproblem_2020;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;

/**
 * Created by zhang_j on 2020/10/28
 */
public class 独一无二的出现次数 {

    public boolean uniqueOccurrences(int[] arr) {
        if(arr == null || arr.length == 0){
            return true;
        }
        Map<Integer, Integer> map = new HashMap<>();
        for (int i : arr) {
            map.put(i, map.getOrDefault(i, 0) + 1);
        }
        return map.values().size() == new HashSet<>(map.values()).size();
    }
}
